﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.GameStateManagment;

namespace Framework.Physics.Collision
{
    class CollisionEasy
    {
        public static KeyboardState _KSCrash;

        public static bool Check(Vector2 pos1, Texture2D tex1, Vector2 pos2, Texture2D tex2)
        {
            //...1 = Tile
            //...2 = Player

            Vector2 temp = Input.MovementNow();
            temp = new Vector2();
            Rectangle rec1 = new Rectangle(Convert.ToInt32(Math.Round((decimal)pos1.X,0)), Convert.ToInt32(Math.Round((decimal)pos1.Y, 0)), tex1.Width, tex1.Height);
            Rectangle rec2 = new Rectangle(Convert.ToInt32(Math.Round(pos2.X + temp.X, 0)), Convert.ToInt32(Math.Round(pos2.Y + temp.Y, 0)), tex2.Width/2, tex2.Height/2);




            if (rec1.Intersects(rec2))
            {
                _KSCrash = Input.KS;

                Vector2 temp2 = new Vector2(0, 0);
                if (Input.KS.IsKeyDown(Keys.W))
                {
                    temp2 -= new Vector2(0, 2.2f);
                }
                if (Input.KS.IsKeyDown(Keys.S))
                {
                    temp2 += new Vector2(0, 2.2f);
                }
                if (Input.KS.IsKeyDown(Keys.A))
                {
                    temp2 -= new Vector2(2.2f, 0);
                }
                if (Input.KS.IsKeyDown(Keys.D))
                {
                    temp2 += new Vector2(2.2f, 0);
                }

                Input.Movement += temp2;
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
